{% extends "layouts" ~ DIR ~ "default.twig" %}

{% block title %}{{ "Manage Categories" | translate("categorize") }}{% endblock %}

{% block content %}
<form class="filters" action="{{ url('manage_category') }}" method="post" accept-charset="UTF-8" role="search">
<fieldset role="presentation">
<label for="query">
{{ "Search&hellip;" | translate }}
<a href="{{ url('help/id/filtering_results') }}" rel="help" target="_blank" class="help emblem">
{{- icon_svg("help.svg", "Help" | translate) -}}
</a>
</label>
<input class="text filter_text" type="text" name="query" value="{{ GET.query | fix(true, true) }}" id="query">
<button type="submit">{{ "Search" | translate }}</button>
<a href="{{ url('new_category') }}" class="button yay"> 
{{ icon_svg("add.svg") }}{{ "New Category" | translate("categorize") }}
</a>
</fieldset>
</form>
<h2>{{ GET.query is not empty ? "Search Results" | translate : "Categories" | translate("categorize") }}</h2>
<table>
<thead> 
<tr class="head">
<th class="category_show emblem">{{ "Listed?" | translate("categorize") }}</th>
<th class="category_name name main">{{ "Name" | translate("categorize") }}</th>
<th class="category_count value">{{ "Posts" | translate("categorize") }}</th>
{{ trigger.call("manage_comments_column_header") }}
<th class="controls" colspan="2">{{ "Controls" | translate }}</th>
</tr>
</thead>
<tbody>
{% for category in categorize %}
<tr id="category_{{ category.id }}">
<td class="category_show emblem">
{% if category.show_on_home %}
{{ icon_svg("success.svg", "Yes" | translate, "emblem") }}
{% endif %}
</td>
<td class="category_name name main">
<a href="{{ category.url }}">{{ category.name | oneof("[Untitled]" | translate) | truncate(40) }}</a>
</td>
<td class="category_count value">
{{ category.post_count }}
</td>
<td class="controls">
{%- if category.editable() -%}
{{ category.edit_link(icon_svg("edit.svg", "Edit" | translate), null, null, "emblem") }}
{%- else -%}
{{ icon_svg("forbidden.svg", false, "emblem forbidden") }}
{%- endif -%}
</td>
<td class="controls">
{%- if category.deletable() -%}
{{ category.delete_link(icon_svg("delete.svg", "Delete" | translate), null, null, "emblem") }}
{%- else -%}
{{ icon_svg("forbidden.svg", false, "emblem forbidden") }}
{%- endif -%}
</td>
</tr>
{% else %}
<tr>
<td class="placeholder">
{{ icon_svg("failure.svg", false, "emblem") }}
{{ "No results" | translate }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
